home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / spectr20.zip / SPEC2.DOC < prev    next >
INI File  |  1992-04-29  |  32KB  |  630 lines

  1. [WS 1 in]
  2.  
  3.                           SPECTRUM CALCULATION ROUTINE
  4.  
  5.                                   Version 2.0
  6.  
  7. [WS 4 in]
  8.  
  9.                                  David E. Hess
  10.                                 Fluid Flow Group
  11.                          Process Measurements Division
  12.                    Chemical Science and Technology Laboratory
  13.                  National Institute of Standards and Technology
  14.                             Email: HESS@ENH.NIST.GOV
  15.                              Phone: (301) 975-5937
  16.  
  17. [WS 0.5 in]
  18.  
  19.                                   [April 1992]
  20.  
  21.  
  22.                            ▒New Features
  23.  
  24.  
  25. *        Two additional window functions are available for tapering the data.
  26.          The first, referred to as the Minimum Sidelobe window, has a maximum
  27.          sidelobe level of -93 dB; the sidelobes then decay at a rate of 18
  28.          dB/octave.  The second window, the Maximum Decay window, has a maximum
  29.          sidelobe level of -61 dB, but these sidelobes decay at a rate of 42
  30.          dB/octave.
  31.  
  32.  
  33. *        The structure of the data files to be processed has been modified to
  34.          allow inclusion of information about the voltage transformation factor
  35.          for each channel of data.  The file format has been changed to BINARY
  36.          in order to permit these data files to be written by programming
  37.          languages other than FORTRAN.
  38.  
  39.  
  40. *        Memory for data arrays is now allocated dynamically at run-time, and
  41.          only the memory needed for the current file being processed is
  42.          allocated at any particular time.  Storage for these arrays can be
  43.          quite large and dynamic allocation of memory reduces the amount of
  44.          storage required within the SPECTRUM executable file.  This
  45.          modification has reduced the size of the executable file by 75%.
  46.  
  47.  
  48. *        All internal temporary files created by the SPECTRUM routine are now
  49.          written in BINARY format.  This saves an additional small amount of
  50.          memory at run-time.
  51.  
  52.  
  53. *        When an input data file consisted of only one channel of data to be
  54.          processed, the first version of SPECTRUM required that this data file
  55.          have an even number of records.  This restriction has been removed.
  56.  
  57.  
  58. *        The manual included with the first version of SPECTRUM provides a
  59.          detailed account of the manner in which the amount of space on the
  60.          hard disk (or Ram disk) required by the routine for storage of
  61.          temporary files may be estimated.  Version 2 of SPECTRUM now
  62.          calculates at run-time the amount of temporary space required to
  63.          process the current file, and then checks the hard disk (or Ram disk)
  64.          to determine if that space is available.
  65.  
  66.  
  67. *        The code has been restructured by removing portions of the code from
  68.          the Main module and placing these segments into functions or
  69.          subroutines.  The subsequent reduction in size of the Main module has
  70.          permitted additional optimization procedures contained within the
  71.          Microsoft Fortran Optimizing Compiler, V 5.1 to be employed.  Also,
  72.          the code for the Main module is now more readable.
  73.  
  74.  
  75. *        All of the utility files included on the diskette have been modified
  76.          to use the new input data file format.  Each of these routines should
  77.          be used only with SPECTRUM V 2.0.
  78.  
  79.  
  80. *        The SPECTRUM routine requires a computer equipped with an 80286 or
  81.          better microprocessor.  An 80287 or better numeric coprocessor is
  82.          recommended but is no longer required.
  83.  
  84.  
  85.  
  86.      All information contained within this document supersedes the information
  87. contained within the manual which refers to version 1.0 of the SPECTRUM
  88. routine.  Any information found in the manual which is not countermanded by
  89. statements made here is considered to still apply.
  90.  
  91.                          ▒Diskette Contents
  92.  
  93.  
  94.      The following files are contained on the diskette.
  95.  
  96.  
  97. SPECTRUM     FOR    66165  04-22-92  8:16a     Main program source code.
  98. SPECTRUM     FI      1852  04-22-92  7:59a     Interface statements.
  99. SPECTRUM     FN      2406  04-22-92  8:04a     Data declaration & common areas.
  100. SPECTRUM     CFG     1197  04-23-92  3:50p     Optional setup file.
  101. SPECTRUM     EXE   111592  04-23-92  3:03p     Works with or w/o a coprocessor.
  102. SPEC387      EXE   103800  04-23-92  2:43p     Works only with a coprocessor.
  103. COLOR        FOR     8314  04-22-92  8:05a     Source for noise generator.
  104. COLOR        EXE    57452  04-23-92  3:07p     Executable for noise generator.
  105. COLOR2       FOR     9073  04-23-92  3:13p     Source for 2-chan noise gen.
  106. COLOR2       EXE    57872  04-23-92  3:13p     Executable for 2-chan noise gen.
  107. SINE         FOR     4371  04-22-92  8:06a     Source for sinewave generator.
  108. SINE         EXE    50490  04-23-92  3:09p     Executable for sinewave gen.
  109. MAKDAT       FOR     8960  04-22-92  8:06a     Ascii to Binary converter
  110. MAKDAT       EXE    51564  04-23-92  3:11p     source.
  111. MAKCOEF      FOR     6296  04-22-92  8:07a     Asc to Bin converter executable.
  112. MAKCOEF      EXE    44388  04-23-92  3:11p     Coefficient file creation
  113. README       1ST     1594  04-28-92  2:54p     source.
  114.                                                Coeff. file creation executable.
  115.                                                Cover letter.
  116.  
  117.  
  118.      The README.1ST file is simply a reminder that this is the second version
  119. of SPECTRUM and that an update to the manual exists and should be read prior to
  120. the first use of the program.  All files with an .FOR, .FI or .FN extension are
  121. Ascii files containing FORTRAN source code for the respective program.  These
  122. files are not required when using SPECTRUM and need not be kept on the hard
  123. disk.  If the SPECTRUM routine is recompiled, then three files are required
  124. during compilation: SPECTRUM.FOR, SPECTRUM.FI and SPECTRUM.FN.  The SPECTRUM.FI
  125. file contains interface statements for the functions and subroutines used in
  126. SPECTRUM, and the SPECTRUM.FN file contains data declaration statements and
  127. COMMON statements which permit data areas to be shared by both the Main module
  128. and other program modules.  These two files are compiled along with the main
  129. program file using the INCLUDE statement in appropriate locations in the main
  130. program source code.  This program was compiled using the Microsoft FORTRAN
  131. Optimizing Compiler, V 5.1.  The command used to compile the code and to
  132. generate the SPECTRUM.EXE file, which may be used with or without a
  133. coprocessor, is given by
  134.  
  135.  
  136.                           FL /G2 /W2 /FPi SPECTRUM.FOR
  137.  
  138.  
  139. In addition, an executable version of SPECTRUM has been provided which will
  140. work only with a numeric coprocessor installed (80287, 80387 or 80486).  This
  141. executable version is called SPEC387.EXE and consists of more streamlined code
  142. which executes somewhat faster.  This version was compiled using the command
  143.  
  144.  
  145.                          FL /G2 /W2 /FPi87 SPECTRUM.FOR
  146.  
  147.  
  148. The use of the SPECTRUM.CFG file is optional and is described in the manual
  149. which accompanied version 1 of SPECTRUM.  The COLOR, COLOR2 and SINE utility
  150. routines generate data with known spectral densities; the data files produced
  151. by these routines are compatible with SPECTRUM and may be used for testing the
  152. operation of the program.  The use of these utility routines is reviewed in
  153. detail in the version 1 manual.  Finally, the MAKDAT and MAKCOEF routines are
  154. used to convert Ascii data files into the BINARY data files required by the
  155. SPECTRUM routine.  These utilities are also explained in the version 1 manual.
  156.  
  157.                         ▒Additional Windows
  158.  
  159.  
  160.      Two additional window functions for tapering the input data are available
  161. in SPECTRUM V 2.0.  These windows have been added as possible alternatives to
  162. the more commonly used windows made available in V 1.0.  The choice of a window
  163. function depends upon such factors as the highest sidelobe level (dB), the rate
  164. of decay of the sidelobes (dB/octave) and the halfwidth of the mainlobe (f T).
  165. In general, as the width of the mainlobe is decreased, thereby increasing the
  166. resolving power, the amplitude of the sidelobes is increased which intensifies
  167. the problem of leakage.  In many cases it is useful to allow the width of the
  168. mainlobe to increase somewhat in order to decrease the height of the sidelobes
  169. and / or to reduce the rate of decrease in the sidelobe level.
  170.  
  171.      With this end in mind, two windows were selected from Nuttall (1981) which
  172. are highly optimized members of a family of windows discussed by Harris
  173. (1978).  The first window, which will be denoted here as the Minimum Sidelobe
  174. window, is the 4-term Blackman window with continuous first derivative.  This
  175. window minimizes the maximum height of the sidelobes and also has a reasonably
  176. good rate of decay of the sidelobes at the expense of a widened mainlobe.  The
  177. second window will be referred to here as the Maximum Decay window; this is the
  178. 4-term Blackman window with continuous fifth derivative which maximizes the
  179. rate of decay of the sidelobes and which also has a low maximum sidelobe
  180. amplitude.  As expected, the mainlobe for this window is also wider than any of
  181. the windows contained in the first version.
  182.  
  183.      These windows are defined by
  184.  
  185.  
  186. [EQN "center #^ w (t) #3#3 = #3#3 #( { #3#3 stack left [[ a sub 0 #3#3 - #3#3 a
  187.  
  188.  
  189.  
  190. where the coefficients for the Minimum Sidelobe window are given by
  191.  
  192.  
  193. [EQN "center a sub 0 #3#3 = #3#3 0.355768 #4#4 a sub 1 #3#3 = #3#3 0.487396 #4#4
  194.  
  195.  
  196.  
  197. and those for the Maximum Decay window by
  198.  
  199.  
  200. [EQN "center a sub 0 #3#3 = #3#3 10 over 32 #4#4 a sub 1 #3#3 = #3#3 15 over 32
  201.  
  202.  
  203.  
  204. These functions are plotted in figure 1 with the Hanning window shown for
  205. comparison.  Notice that the Hanning window is a member of this family of
  206. windows where the first two coefficients are 1/2 and the remaining coefficients
  207. are zero.[PB]
  208.  
  209. The Fourier transforms for these windows are found to be
  210.  
  211.  
  212. [EQN "center W #1 (f,T) #3#3 = #3#3 { #3#3 a sub 0 #3#3 #[ [sin #3 pi f T] over
  213.  
  214.  
  215.  
  216. where  [EQN "f sub 1 #3 = #3 1 #1 / #1 T"] .  The moduli of the Fourier
  217. transforms for each of the above windows as well as for the Hanning window,
  218. shown for comparison, are plotted in figures 2, 3 and 4.  In order to clearly
  219. reveal the maximum sidelobe height and the rate of decay of these sidelobes,
  220. the vertical axes of the plots are magnified by using a logarithmic scale; the
  221. power response of the windows normalized by the peak response at
  222. [EQN "f #3 = #3 0"]  and converted to decibels is defined by
  223.  
  224.  
  225. [EQN "center #R[dB] #3#3 = #3#3 10 #3 #R[log] #3 [| W(f) #1 / #1 W(0)|] super 2"
  226.  
  227.  
  228.  
  229. The plots clearly show the optimal features for each window function.  A list
  230. of the performance parameters for all of the windows contained within SPECTRUM
  231. is included below for completeness.
  232.  
  233.  
  234.  
  235.  
  236.                              Maximum        Maximum      Halfwidth of
  237.               Window         Sidelobe        Decay         Mainlobe
  238.                Type            (dB)       (dB/octave)       (f T)
  239.  
  240.               Square           -13             6             1.0
  241.                Tukey           -13             18            1.1
  242.               Hanning          -31             18            2.0
  243.               Parzen           -27             12            2.0
  244.                Welch           -21             12            1.4
  245.            Min. Sidelobe       -93             18            4.0
  246.             Max. Decay         -61             42            4.0
  247.  
  248.  
  249.  
  250.                      Table 1  Window performance parameters
  251.  
  252.  
  253.  
  254.                                  [PIC FIG1.CGM]
  255.  
  256.                 Figure 1  Additional window functions for tapering the data
  257.  
  258.                                   [WS 0.5 in]
  259.  
  260.                                  [PIC FIG2.CGM]
  261.  
  262.                       Figure 2  Power response for Hanning window[PB]
  263.  
  264.                                  [PIC FIG3.CGM]
  265.  
  266.                     Figure 3  Power response for minimum sidelobe window
  267.  
  268.                                   [WS 0.5 in]
  269.  
  270.                                  [PIC FIG4.CGM]
  271.  
  272.                      Figure 4  Power response for maximum decay window
  273.  
  274.                      Input Data File Structure
  275.  
  276.  
  277.      The author has obtained a new A/D converter which has the capability of
  278. altering the input voltage range to be digitized.  The selection of an input
  279. voltage range may be made via software as opposed to changing jumpers on the
  280. board itself.  After data has been sampled by the A/D converter, the author
  281. has, in the past, written certain information to the first record of each data
  282. file which describes the digitized information that follows.  With the added
  283. capability offered by the new A/D converter, it was felt that the input voltage
  284. range used by each channel in the input data file would be prudent pieces of
  285. information to add to the file header.  The A/D converter has the ability to
  286. convert up to eight differential inputs sequentially, and each channel may use
  287. a different input voltage range.  Therefore, data files from this A/D converter
  288. may contain up to eight channels of digitized information, and the second
  289. record of the data file is now used to record the input voltage range used by
  290. each channel.  These input data files are then used by a variety of routines
  291. written by the author to perform various aspects of random data analysis.  The
  292. SPECTRUM program is just one member of this family of routines.  Since the
  293. SPECTRUM program can only process one or two channels of data, placing
  294. information on the voltage range used by up to eight channels of data leads to
  295. unnecessary information being included for six channels which do not exist.  As
  296. silly as this may seem, it turns out to be useful for the author to adopt a
  297. single universal input data file structure which can then be used by all of the
  298. routines which examine this data file.  Therefore, this input data file
  299. structure, while not optimal for the SPECTRUM program, is the most useful
  300. universal setup for the author at this time.
  301.  
  302.      All input data files must be sequential BINARY files.  These files contain
  303. no internal formatting information, and thus, are the most useful type of files
  304. to use when dealing with large quantities of data.  Sequential unformatted
  305. FORTRAN data files were used as the file type for input data files in the first
  306. version of SPECTRUM.  The drawback with unformatted FORTRAN data files is that
  307. they may be written only by FORTRAN programs.  Using BINARY data files allows
  308. the data to be written using other programming languages.  Furthermore,
  309. unformatted FORTRAN data files do, in fact, use a small amount of internal
  310. formatting information, whereas BINARY files do not.  Thus, BINARY data files
  311. are slightly smaller than unformatted FORTRAN data files.  The first two
  312. records of the data file contain descriptive information about the digitized
  313. data to follow and form the file header.  Following the file header is the
  314. actual digitized data.  The first record of the file header is changed only
  315. slightly from version 1.0 of the SPECTRUM routine, and the text describing this
  316. first record is taken from the manual issued with the first version.  Changes
  317. are noted in boldface text as required.
  318.  
  319.      The first record of the data file consists of a header containing four
  320. quantities which characterize the data which follows. The first quantity is a
  321. 2-byte integer which gives the number of channels of data per record (1 or 2).
  322. The next number is the record size in bytes and must be a 4-byte integer.  The
  323. record size is twice the number of points per record if the data consists of
  324. 2-byte integer values, or the record size is four times the number of points
  325. per record if the data consists of 4-byte real data.  The third quantity is a
  326. 2-byte integer which gives the number of records of data which follow, and the
  327. last quantity is the time interval in microseconds between data points of the
  328. same channel expressed as a 4-byte integer.  Recall that the largest positive
  329. signed number that may be stored as a 2-byte integer is 32,767 and, for a
  330. 4-byte integer, the value is 2,147,483,647.
  331.  
  332.      For example, suppose the data file consists of 100 records of one channel
  333. of data saved as 2-byte integers and sampled at 10000 samples per second with
  334. 2048 data points per record.  The first record of the data file would contain
  335. the four values:
  336.  
  337.  
  338. [EQN "center 1 #4#4 4096 #4#4 100 #4#4 100 #4#4"]
  339.  
  340.  
  341. Now suppose that two channels of data were sampled with a time interval of
  342. 0.016383 seconds between each successive data point resulting in a time
  343. interval of 0.032766 seconds between each successive data point of the same
  344. channel.  Furthermore, 40 records of data were sampled with 8192 data points
  345. per record such that each channel of data consisted of 4096 data points.
  346. Finally, the data were transformed into desired quantities and saved as 4-byte
  347. floating-point numbers.  The first record for this data file should consist of
  348. the following four numbers:
  349.  
  350.  
  351. [EQN "center 2 #4#4 32768 #4#4 40 #4#4 32766"]
  352.  
  353.  
  354.      The second record of the data file consists of eight 2-byte integer values
  355. which encode the input voltage range used by channels 1 to 8.  Acceptable
  356. values are
  357.  
  358.  
  359. [EQN "center matrix [[[# ] [# ] [# ] [# ] [# ] [# ] [#R[Value]] [# ] [#R[Range]]
  360.  
  361.  
  362.  
  363. The user should write a 2-byte integer value from 0 to 3 to indicate the
  364. voltage range used by the first channel and the second channel.  Six additional
  365. zero values must be entered for channels 3 through 8 which are not used by the
  366. SPECTRUM routine.  For example, to indicate that the input voltage range for
  367. the first channel was -5V to 5V and for the second channel was -1.25V to 1.25V,
  368. the user would write the following to the second record of the data file.
  369.  
  370.  
  371. [EQN "center 1 #3#3 3 #3#3 0 #3#3 0 #3#3 0 #3#3 0 #3#3 0 #3#3 0 #3#3"]
  372.  
  373.  
  374. When the SPECTRUM program is run, the routine will ask if an alternate voltage
  375. transformation factor should be used.  If the user responds with yes, then the
  376. user must type in the voltage per digital level conversion factor to be used
  377. for that channel, and this factor will be used in place of the factor stored in
  378. record 2 of the data file.  After reading in the data file, the SPECTRUM
  379. routine will convert the digitized data back into voltages using the conversion
  380. factors shown above.  If none of the above voltage ranges are appropriate for a
  381. particular data file, then the user should proceed as follows.  Store eight
  382. zero values (2-byte integers) on the second record of the data file.  Then,
  383. execute the SPECTRUM routine and enter the appropriate alternate conversion
  384. factor when requested.
  385.  
  386.      Following the first two records containing the file header is the actual
  387. data.  When the data comes directly from an analog to digital converter
  388. (12-bit, say), then the values range from -2048 to 2047 (or 0 to 4095) and are
  389. appropriately stored as 2-byte integers.  Alternatively, if some preprocessing
  390. is typically performed on the data, the data may be stored as 4-byte
  391. floating-point numbers.  As a result of the Fast Fourier Transform (FFT)
  392. algorithm used in this routine, the number of data points per channel per
  393. record must be a power of 2.
  394.  
  395.      In the first version of SPECTRUM, the program required an even number of
  396. records of data in the input data file when the file consisted of one channel
  397. of sampled data.  This is no longer required.  When the program submits the
  398. data to the FFT module to be transformed, two records are submitted to the FFT
  399. algorithm to be transformed simultaneously as a time-saving measure.  If an odd
  400. number of records is detected in the input data file in the case of one channel
  401. of data, then the program automatically appends an additional record of data
  402. containing a copy of the data values of the previous record.  After
  403. transformation, the results of the added record are discarded so that the
  404. output is not corrupted by the internal addition of a record of data.  When two
  405. channels of data are sampled, an even or odd number of records is not a factor
  406. because one record from each channel is submitted to the FFT module for
  407. simultaneous transformation.
  408.  
  409.      One or two separate time series (channels) may be stored per record.  The
  410. method of storing the data values in each record follows the standard procedure
  411. used by analog to digital converters:
  412.  
  413.  
  414. [EQN "center #R[one] #4 #R[channel] #^ #R[:] #4#4 x sub 0 #3 x sub 1 #3 x sub 2
  415.  
  416.  
  417.  
  418. where the notation is as defined above.  This convention must be followed even
  419. if the data are processed and then stored as floating-point numbers.  When two
  420. channels of data are sampled and then stored to a data file, the values for
  421. each channel of data should be of the same data type: either 2-byte integers or
  422. 4-byte floating-point numbers.  If the user is unfamiliar with the task of
  423. creating BINARY data files, then the user may instead create these files in an
  424. ASCII file format.  A utility MAKDAT which is included on the diskette can then
  425. be used to write the file header and transform the ASCII data files into the
  426. BINARY data files required by the spectrum routine.  See the section on utility
  427. files in the manual included with version 1.0.
  428.  
  429.      This section gives a few lines of code which are representative of the
  430. manner in which these data files are written and read.  When writing, the file
  431. is first opened, the file header is written, the data is written and then the
  432. file is closed.
  433.  
  434.  
  435.                    INTEGER*2 ICHANS, NUMREC
  436.                    INTEGER*4 IRSIZE, IDELTMS, N, I
  437.                    INTEGER*2 NDATA (NMAX), GAIN (0 : 7)
  438.  
  439.                    OPEN (2, FILE = 'A001.DAT', STATUS = 'UNKNOWN',
  440.                          ACCESS = 'SEQUENTIAL', FORM = 'BINARY')
  441.  
  442.                    WRITE (2) ICHANS, IRSIZE, NUMREC, IDELTMS
  443.                    WRITE (2) (GAIN (I), I = 0, 7)
  444.  
  445.                    DO J = 1, NUMREC
  446.                       ... put data record into NDATA array ...
  447.                      WRITE (2) (NDATA (I), I = 1, N)
  448.                       ... get next record of data ...
  449.                    ENDDO
  450.  
  451.                    CLOSE (2, STATUS = 'KEEP')
  452.  
  453.  
  454.      The same procedure is followed when the data file is opened and read by
  455. the spectrum routine.  The file is opened, the file header is read, the data is
  456. read and then the file is closed.
  457.  
  458.  
  459.  
  460.                    INTEGER*2 ICHANS, NUMREC
  461.                    INTEGER*4 IRSIZE, IDELTMS, N, I
  462.                    INTEGER*2 NDATA (NMAX), GAIN (0 : 7)
  463.  
  464.                    OPEN (2, FILE = 'A001.DAT', STATUS = 'OLD',
  465.                          ACCESS = 'SEQUENTIAL', FORM = 'BINARY')
  466.  
  467.                    READ (2) ICHANS, IRSIZE, NUMREC, IDELTMS
  468.                    READ (2) (GAIN (I), I = 0, 7)
  469.  
  470.                    N = IRSIZE/2
  471.                    DELT = FLOAT (IDELTMS) / 1000000.0
  472.  
  473.                    DO J = 1, NUMREC
  474.                      READ (2) (NDATA (I), I = 1, N)
  475.                       ... process this record of data ...
  476.                    ENDDO
  477.  
  478.                    CLOSE (2, STATUS = 'KEEP')
  479.  
  480.  
  481.                       MAKCOEF Utility Routine
  482.  
  483.  
  484.      The use of this utility routine for the generation of coefficient data
  485. files for use with SPECTRUM is essentially the same.  The output of the program
  486. is now a BINARY coefficient data file vis a vis the unformatted FORTRAN
  487. coefficient data file generated in the first version.  The SPECTRUM routine now
  488. allocates memory dynamically for all internal arrays at run-time.  This
  489. improvement in the main program has unfortunately introduced an additional
  490. restriction on the generation of coefficient data files.  The first set of
  491. coefficients contained in the coefficient data file must correspond to the
  492. first file to be processed by SPECTRUM, and the last set of coefficients
  493. contained in the coefficient data file must correspond to the last file to be
  494. processed by SPECTRUM.  The total number of sets of coefficients contained in
  495. the coefficient data file should be given by
  496.  
  497.  
  498. [EQN "center #R[numsets] #3#3 = #3#3 #R[last] #3#3 - #3#3 #R[first] #3#3 + #3#3
  499.  
  500.  
  501.  
  502. The total number of files processed by SPECTRUM need not match the total number
  503. of sets of coefficients contained in the coefficient data file as long as the
  504. first and last sets of coefficients correspond to the first and last files
  505. processed, and the remainder of the files to be processed correspond to sets of
  506. coefficients that are contained between the first and last sets in the
  507. coefficient data file.  This restriction will be clarified below using the
  508. example given on pp 70-71 from the manual included with the first version.
  509.  
  510.      Suppose that it was desired to process the data files D061.DAT thru
  511. D086.DAT in a batch by the spectrum routine.  Each of these data files
  512. consisted of two channels of 2-byte integers taken from an experiment in fluid
  513. mechanics, say.  Furthermore, suppose that the quantities sampled were two
  514. components of a fluid velocity, which were transduced into voltages by some
  515. means and then sampled by an A/D converter.  The user knows the calibration
  516. data for the transducer, and the required transformation from voltages back
  517. into velocities can be accomplished for each velocity component by using a
  518. polynomial of up to fourth degree in the form:
  519.  
  520.  
  521. [EQN "center u sub n #3#3 = #3#3 b sub 0 #3 + #3 b sub 1 v sub n #3 + #3 b sub 2
  522.  
  523.  
  524.  
  525. where  [EQN "v sub n"]  is the nth data point expressed as a voltage,
  526. [EQN "b sub 0 #1 , #3 b sub 1 #1 , ... , b sub 4"]  are the coefficients of the
  527. velocity transformation and  [EQN "u sub n"]  is the nth data point which has
  528. been converted to a velocity.  Now, suppose further that the data in each of
  529. the files were taken over a period of time in which the calibration
  530. coefficients changed; thus, a different set of coefficients are required for
  531. each of the 26 files to be processed.  Following the instructions in the
  532. section on coefficient data files, this scenario would require the creation of
  533. two BINARY coefficient data files, DCON.DAT and DCON2.DAT, each containing the
  534. 26 sets of five coefficients  [EQN "b sub 0 #1 , #3 b sub 1 #1 , ... , b sub 4"]
  535.   for the velocity transformation for channel 1 and channel 2, respectively.
  536.  
  537.      The user should create each ASCII data file with a four character name
  538. followed by the extension [.ASC].  The names should conform to the various
  539. naming conventions specified earlier.  The ASCII file must contain numbers
  540. only, although blank lines may be inserted into the file if desired.  The
  541. numbers will be transferred to 4-byte floating point quantities in the
  542. unformatted data file thereby limiting the coefficients to single precision (6
  543. or 7 decimal places).  The coefficients may be stored one per line or many per
  544. line in the ASCII file.  The first number in the file will be  [EQN "b sub 0"]
  545. for channel 1 of data file D061.DAT; the fifth number in the file should be
  546. [EQN "b sub 4"]  for channel 1 of data file D061.DAT; the sixth number in the
  547. file will be  [EQN "b sub 0"]  for channel 1 of data file D062.DAT, and so on.
  548. The 130th and last number in the file should be  [EQN "b sub 4"]  for channel 1
  549. of data file D086.DAT.  The user should then create a second ASCII file in a
  550. similar manner specifying all of the coefficients for channel 2 of the 26 files
  551. to be processed.  The utility MAKCOEF should then be executed twice, first
  552. transferring the contents of the first ASCII file (for channel 1) to DCON.DAT
  553. and then for the second ASCII file (for channel 2) to DCON2.DAT.  A session
  554. using MAKCOEF would proceed as follows.
  555.  
  556.  
  557. makcoef
  558.  
  559. Enter first letter of data file to
  560. which these coefficients will be associated : d
  561.  
  562. Are these coefficients for channel (1 or 2) : 1
  563.  
  564. Enter # of sets of coefficients : 26
  565.  
  566. Enter starting file number : 61
  567.  
  568. Enter ASCII input file name (4 chars) : chn1
  569.  
  570.         C O E F F I C I E N T   F I L E   C R E A T I O N   U T I L I T Y
  571.  
  572.                        Creating DCON.DAT now.
  573.  
  574.                        # sets of coeffs = 26
  575.                        # coeffs in each set = 5
  576.                        # of starting file = 61
  577.  
  578.                        Program terminated successfully.
  579.  
  580.  
  581. The MAKCOEF routine will read the ASCII file CHN1.ASC and will write the
  582. following file header to the BINARY file DCON.DAT:
  583.  
  584.  
  585. [EQN "center 26 #4#4 61"]
  586.  
  587.  
  588. The coefficients for channel 1 are then transferred to the BINARY file.  Note
  589. that 5 coefficients per set are required; therefore, this number is not written
  590. to the file header.  If, at a later time, the user wishes to reprocess the
  591. files D074.DAT through D080.DAT (perhaps specifying different options in the
  592. spectrum routine), it is necessary to re-create the two coefficient data files;
  593. the new data files will contain 7 sets of coefficients beginning with those
  594. corresponding to D074.DAT and ending with those corresponding to D080.DAT.  If
  595. the user wishes to process the data files in an arbitrarily numbered order (not
  596. consecutively), the coefficient data files may need to be changed.  For
  597. example, if the files D064.DAT, D069.DAT and D086.DAT were to be processed by
  598. SPECTRUM, this would necessitate a change in the coefficient data files
  599. requiring 23 sets of coefficients in each file: the first set corresponding to
  600. D064.DAT and the last set to D086.DAT.  On the other hand, the files D061.DAT,
  601. D064.DAT, D069.DAT and D086.DAT could be processed by SPECTRUM without changing
  602. the coefficient data files since the first and last files correspond to the
  603. first and last sets of coefficients.  The converse is also true, however.  If
  604. the user desires at the outset to process only the four arbitrarily ordered
  605. files in the latter case above, two coefficient data files must be created
  606. which contain not 4, but 26 sets of 5 coefficients for the data files D061.DAT
  607. through D086.DAT.  The spectrum routine requires that sets of coefficients in
  608. the coefficient data file be listed for consecutively numbered files even if
  609. not all of the sets of coefficients are used.  With this in mind, it is perhaps
  610. best to store all of the coefficients for an entire set of input data files in
  611. a master ASCII file; then members of the set can be processed by the spectrum
  612. routine either consecutively or in an arbitrarily numbered order at any
  613. subsequent time and the BINARY coefficient data files can be easily created by
  614. editing the master ASCII file and using MAKCOEF.  Of course, the user could
  615. transform the voltages back into dimensional quantities using his/her own code
  616. and store the resulting floating-point numbers into ASCII data files (then use
  617. MAKDAT) or directly into BINARY data files to be processed by SPECTRUM; then,
  618. all of this mess concerning coefficient data files could be avoided altogether.
  619.  
  620.                             *References
  621.  
  622.  
  623. Harris, F.J. 1978 On the use of windows for harmonic analysis with the discrete
  624.      Fourier transform, Proceedings of the IEEE, 66, 51-83.
  625.  
  626.  
  627. Nuttall, A.H. 1981 Some windows with very good sidelobe behavior, IEEE
  628.      Transactions on Acoustics, Speech and Signal Processing, ASSP-29, 84-91.
  629.  
  630.